import * as mutationtypes from '../mutation-types';
import Vue from 'vue';

const state = {
  shops: [],
  selectshop: {}
};
// actions
const actions = {
  refreshShops({commit}) {
    return Vue.axios.get('/WechatMall/Shop/getshops').then((response) => {
      if (response.data.isSuccess) {
        commit(mutationtypes.SET_SHOPS, response.data.shops);
      }
    });
  }
};
const getters = {};
// mutations
const mutations = {
  [mutationtypes.SET_SHOPS](state, shops) {
    state.shops = shops;
  },
  [mutationtypes.SET_SELECTEDSHOP](state, shop) {
    state.selectshop = shop;
  }
};

const shop = {
  state: state,
  getters: getters,
  actions: actions,
  mutations: mutations
};
export default shop;
